package com.ljx.controller;
import com.ljx.Vo.Result;
import com.ljx.entitl.Dept;
import com.ljx.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/17 17:17
 * @Version 1.0
 * swagger注解常用描述
 * https://blog.csdn.net/m0_37899908/article/details/125399361
 * https://blog.csdn.net/weixin_43935927/article/details/113401678
 */
@RestController
@RequestMapping("/dept")
@Api(tags="对dept表的增删改查" )
public class DeptController {
	@Autowired
	private DeptService deptService;
	@ApiOperation(value = "分页查询部门信息表")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "currentPage" ,value = "当前第几页",dataType = "int"),
			@ApiImplicitParam(name = "pageSize",value = "每页多少条数据" ,dataType = "int",required =true)
	})
	@GetMapping("/selectAll")
	public Result select(@RequestParam(defaultValue = "1")int currentPage,@RequestParam(defaultValue = "3")int pageSize){
		System.out.println(currentPage+"----------------------"+pageSize);
		return deptService.findAllDept(currentPage,pageSize);
	}
	@ApiOperation(value = "更新部门表信息")
	@PutMapping("/update")
	public Result update(@RequestBody Dept dept){
		System.out.println(dept);
		return deptService.updateDept(dept);
	}
	@ApiOperation(value = "插入部门信息")
	@PostMapping("/insert")
	public Result insert(@RequestBody Dept dept){
		System.out.println(dept);
		return deptService.insert(dept);
	}
	@ApiOperation(value = "根据id删除部门信息")
	@DeleteMapping("/delete")
	public Result delete(int id){
		System.out.println(id);
		return deptService.delete(id);
	}
}
